package com.jerry.huihome.module.find.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jerry.huihome.R;
import com.jerry.huihome.base.BaseApplication;
import com.jerry.huihome.base.BaseViewHolder;
import com.jerry.huihome.base.MyBaseAdapter;
import com.jerry.huihome.module.find.entity.ForemanDetail;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/13.
 */
public class ForemanWorksAdapter extends MyBaseAdapter<ForemanDetail.BodyBean.ProjItemsBean> {
    private DisplayImageOptions options;
    public ForemanWorksAdapter(Context context, List<ForemanDetail.BodyBean.ProjItemsBean> list) {
        super(context, list);
        options = new DisplayImageOptions.Builder().cacheInMemory(true)
                .cacheOnDisk(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .build();
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_place;
    }

    @Override
    public BaseViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public void bindViews(View view, BaseViewHolder viewHolder) {
        ForemanDetail.BodyBean.ProjItemsBean projsBean = getItem(viewHolder.position);
        ViewHolder mViewHolder = (ViewHolder) viewHolder;
        mViewHolder.tvHouseName.setText(projsBean.getProjname());
        mViewHolder.tvHouseStyle.setText(projsBean.getDecoStyle());
        mViewHolder.tvHouseSize.setText(projsBean.getHouseArea()+"平方");
        mViewHolder.tvRoomNum.setText(projsBean.getDecoStyle());
        mViewHolder.tvPrice.setText(projsBean.getPrice()+"万");
        mViewHolder.tvMode.setText("-"+projsBean.getMode());
        BaseApplication.getApplication().getImageLoader().displayImage(projsBean.getDoneimg(),mViewHolder.ivHouseImg,options);
    }

    class ViewHolder extends BaseViewHolder{
        @BindView(R.id.iv_house_img)
        ImageView ivHouseImg;
        @BindView(R.id.tv_house_name)
        TextView tvHouseName;
        @BindView(R.id.tv_room_num)
        TextView tvRoomNum;
        @BindView(R.id.tv_house_size)
        TextView tvHouseSize;
        @BindView(R.id.tv_house_style)
        TextView tvHouseStyle;
        @BindView(R.id.tv_price)
        TextView tvPrice;
        @BindView(R.id.tv_mode)
        TextView tvMode;

    }

}
